<?php


namespace app\common\model;


class HealthGoal extends BaseModel
{
    public $name = 'health_goal';

    public function getLists(string $patientId): \think\Paginator
    {
        return $this->where('patient_id', $patientId)
            ->field(["id", "created_at", "creator_id", "creator_name", "theme_name"])
            ->order('created_at', 'desc')
            ->paginate($this->pageLimit);
    }

    public function setPlanTimesAttr($value, $data)
    {

        [$startDate, $endDate] = $data['plan_date'];
        $date1 = new \DateTime($startDate);
        $date2 = new \DateTime($endDate);
        return $date2->diff($date1)->days;
    }
}